package utils

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// BindJSON 绑定 JSON 参数
func Jons2Type(c *gin.Context, obj interface{}) error {
	if err := c.ShouldBindJSON(obj); err != nil {
		c.JSON(http.StatusBadRequest, Response{
			Code:    http.StatusBadRequest,
			Message: "Invalid parameters",
			Data:    err.Error(),
		})
		return err
	}
	return nil
}
